package org.c41.math;

import org.c41.util.Check;

public class Vector2D {

	private Rational x;
	private Rational y;
	
	public Vector2D(Rational x, Rational y){
		Check.notNull(x);
		Check.notNull(y);
		this.x=x;
		this.y=y;
	}
	
	public Rational getX(){
		return this.x;
	}
	
	public Rational getY(){
		return this.y;
	}
	
	@Override
	public boolean equals(Object obj){
		if(!(obj instanceof Vector2D)){
			return false;
		}
		Vector2D v2d = (Vector2D)obj;
		return this.x.equals(v2d.x) && this.y.equals(v2d.y);
		
	}
	
	@Override
	public int hashCode(){
		return x.hashCode()*y.hashCode()*y.hashCode();
	}
	
	@Override
	public String toString(){
		return "("+x+", "+y+")";
	}
	
}
